
<?php
include("include/haut.php");
?>
<?php
	if(isset($_POST['email']) AND isset($_POST['pass'])){
		if(empty($_POST['email']) OR empty($_POST['pass'])){
			header("Location: connexion.php?err=1");
		}
		else{
			$email = htmlentities($_POST['email']);
			$email = mysql_real_escape_string($email);
			$pass = md5($_POST['pass']);
			if(checkMembre($email, $pass)){
				$id = getID($email);
				$_SESSION['id'] = $id;
				$_SESSION['online'] = true;
				header("Location: index.php");
			}
			else
			{
				header("Location: connexion.php?err=2");
			}
		}
	}
	?>
<div id="corps">
	<h1>Connexion</h1>
	<div id="centre">

		<?php
		if( isset($_GET['err']) ){
			if($_GET['err']==1){ ?>
			<div id="msg_erreur">
				<p><b>Erreur:</b><br />
					Merci de remplir tous les champs</p>
			</div>
			<?php }
			if($_GET['err']==2){ ?>
			<div id="msg_erreur">
				<p><b>Erreur:</b><br />
					Aucune correspondance email/mot de passe trouvée</p>
			</div><?php
			}
		}
		?>

	<p>Pour vous connecter merci de remplir les champs suivants:</p>
	<form method="POST" action="#">
		<p>
		<label for="email">Email:</label><br/>
		<input type="text" name="email" id="email"/><br/>
		<label for="pass">Mot de Passe:</label><br/>
		<input type="password" name="pass" id="pass"/></p>
		<input type="submit" value="Se connecter"/>
	</form>
</div>
<?php
include("include/bas.php");
?>